package com.utc.fjc.command.oemimport;

import java.io.File;

import com.teamcenter.rac.aif.AbstractAIFOperation;
import com.utc.teamcenter.common.app.base.BaseBeanDialog;
import com.utc.teamcenter.common.app.dialog.bean.BeanChooserFile;
import com.utc.teamcenter.common.util.EclipseUtil;

public class OemImportDiolag extends BaseBeanDialog {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private BeanChooserFile chooserFile = null;

	@Override
	public void initalBeanComponents() {
		this.chooserFile = new BeanChooserFile(
				"file", //$NON-NLS-1$
				com.utc.fjc.command.oemimport.Messages.OemImportDiolag_1,
				"", "C:\\Siemens\\Temp\\", true, new String[] { ".xls", //$NON-NLS-2$ //$NON-NLS-3$
						".xlsx" }); //$NON-NLS-1$

		super.addBeanComponent(this.chooserFile);
	}

	@Override
	public AbstractAIFOperation getOperation() {
		return new OemImportOperation(this.chooserFile.getText());
	}

	@Override
	public String getTitle() {
		return com.utc.fjc.command.oemimport.Messages.OemImportDiolag_0;
	}
	
	@Override
	public boolean isReady() {
		String filepath = this.chooserFile.getText();
		File file = new File(filepath);

		if ("".equals(filepath) || !file.isFile() || !file.exists()) { //$NON-NLS-1$
			EclipseUtil.error(Messages.OemImportDiolag_2 + filepath);
			return false;
		}
		return super.isReady();
	}

}
